package ch06.Main;

import java.util.Arrays;
import java.util.Scanner;
 abstract class  Shape{
    static double PI=3.14;
    public abstract double getPerimeter();
    public abstract double getArea();
}
class RecTangle extends Shape{
    private int width;
    private int length;
RecTangle(int width,int length){
    this.width=width;
    this.length=length;
}
    @Override
    public double getPerimeter() {
       return (width+length)*2;
    }

    @Override
    public double getArea() {
        return width*length;
    }

    @Override
    public String toString() {
        return "RecTangle{" +
                "width=" + width +
                ", length=" + length +
                '}';
    }
}
class Circle extends Shape{
     private int radius;

Circle(int radius){
    this.radius=radius  ;
}
    @Override
    public double getPerimeter() {
        return 2*PI*radius;
    }

    @Override
    public double getArea() {
        return PI*radius*radius;
    }

    @Override
    public String toString() {
        return "Circle{" +
                "radius=" + radius +
                '}';
    }
}
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Shape arr[] = new Shape[n];
        sc.nextLine();
        for(int i=0;i<n;i++){
            String line = sc.nextLine();

            if(line.equals("rect")){
                int width = sc.nextInt();
                int length = sc.nextInt();
                arr[i]=new RecTangle(width,length);
                sc.nextLine();
            }else if(line.equals("cir")){
                int radius = sc.nextInt();
                arr[i]=new Circle(radius);
                sc.nextLine();
            }
        }
        System.out.println(sumAllperimeter(arr));
        System.out.println(sumAllarea(arr));
        System.out.println(Arrays.toString(arr));
for(Shape s:arr){
    System.out.println(s.getClass()+","+s.getClass().getSuperclass());
}
    }
    public static double sumAllperimeter(Shape []ss){
        double ret=0;
        for(Shape s:ss){
            ret+=s.getPerimeter();
        }
        return ret;
    }
    public static double sumAllarea(Shape []ss){
        double ret=0;
        for(Shape s:ss){
            ret+=s.getArea();
        }
        return ret;
    }
}
